/* eslint-disable */
import React, { Component } from 'react';
import style from "./market.module.css"
import { CaretUpOutlined } from '@ant-design/icons';
import {connect} from "react-redux"
import axios from 'axios'
class market extends Component {
    state={
        hangqing:{}
    }
    componentDidMount(res){
        let dizhi = this.props.dizhi
        const headerJSON = {
            "Content-Type": "application/json;charset=UTF-8"
        };
        axios({
            url:"/shop/avg",
            method:"post",
            header:headerJSON,
            data:{
                places:dizhi.name
            }
        }).then(res=>{
            console.log(res)
            this.setState({
                hangqing:res.data,  
            })
             console.log(this.state.hangqing,"hangqing")
            
        })
    }
    render() {
        let dizhi = this.props.dizhi
        
        return (
            <div className={style.market}>
                <h5 className={style.marketTil}>房价行情</h5>
                <div className={style.marketBox}>
                    <div className={style.marketCity}>
                        <p><b>{dizhi.name}</b></p>
                        <p>城市行情</p>
                    </div>
                    <div className={style.avePrice}>
                        <p><b>{this.state.hangqing.avg}</b>元/㎡起</p>
                        <p>最新均价</p>
                    </div>
                    <div className={style.avePrice}>
                        <p> <CaretUpOutlined style={{color:"#ff5243"}}/>
                            <b>{Number(this.state.hangqing.ff).toFixed(2)}</b>%</p>
                        <p>环比上月</p>
                    </div>
                </div>
            </div>
        );
    }
}

export default connect(
    state => ({
        dizhi : state.citylist
    }),
)(market)